Module modXML
    Public Sub writeConfiguration()
        Dim xml As Xml.XmlTextWriter

        xml = New Xml.XmlTextWriter(Application.StartupPath & "\serverConfig.xml", Nothing)

        With xml
            .Indentation = 4
            .IndentChar = " "
            .Formatting = .Indentation
            .WriteStartDocument()

            .WriteComment("ERN Server Version: " & commonGlobals.ernAdminVersion)
            .WriteStartElement("General")
            .WriteElementString("dbServerName", dbServerName)
            .WriteElementString("dbUserName", dbUserName)
            .WriteElementString("dbPassword", dbPassword)
            .WriteElementString("dbName", dbName)
            .WriteElementString("dbType", dbType)

            .WriteEndElement() 'end GENERAL

            .WriteEndDocument()
            .Flush()
            .Close()
        End With
    End Sub

    Public Sub readConfiguration()
        Dim xml As New Xml.XmlDocument
        Dim nodeList As Xml.XmlNodeList
        Dim node As Xml.XmlNode

        If System.IO.File.Exists(Application.StartupPath & "\serverConfig.xml") Then
            xml.Load(Application.StartupPath & "\serverConfig.xml")
            nodeList = xml.SelectNodes("/General")
            For Each node In nodeList
                dbServerName = node.ChildNodes.Item(0).InnerText
                dbUserName = node.ChildNodes.Item(1).InnerText
                dbPassword = node.ChildNodes.Item(2).InnerText
                dbName = node.ChildNodes.Item(3).InnerText
                dbType = node.ChildNodes.Item(4).InnerText
            Next
        End If
    End Sub
End Module
